<template>
  <button @click="goBack" class="back-button">返回首页</button>
</template>

<script>
export default {
  methods:{
    goBack(){
        this.$router.push('/')
    }
  }
}
</script>

/**样式作用域隔离‌：scoped属性确保组件的样式只作用于该组件内部的元素 */
<style scoped> 
.back-button {
  padding: 8px 16px;
  background-color: #42b983;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.back-button:hover {
  background-color: #3aa876;
}
</style>